package com.lzy.business.controller;

import com.github.pagehelper.PageInfo;
import com.lzy.business.request.MemberCheckLogRequest;
import com.lzy.business.request.OrderProductRequest;
import com.lzy.business.response.MemberCheckLogResponse;
import com.lzy.business.response.ProductClassifyResponse;
import com.lzy.common.constants.BusinessType;
import com.lzy.coupon.apis.MotorcycleServiceApi;
import com.lzy.coupon.dtos.MotorcycleDto;
import com.lzy.framework.component.PageBean;
import com.lzy.framework.core.datasource.multiple.DataSource;
import com.lzy.framework.core.datasource.multiple.DataSourceHolder;
import com.lzy.framework.core.ensure.Ensure;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.member.apis.MemberCheckLogServiceApi;
import com.lzy.member.apis.MemberUserRoleServiceApi;
import com.lzy.member.dtos.MemberCheckLogDto;
import com.lzy.member.dtos.MemberUserRoleDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by WIN7 on 2018/4/7.
 */
@Controller
@RequestMapping(value = "/admin/check/log")
public class MemberCheckLogController{

    private static final Logger LOGGER = LoggerFactory.getLogger(MemberCheckLogController.class);

    @Autowired
    MotorcycleServiceApi motorcycleServiceApi;

    @Autowired
    MemberCheckLogServiceApi memberCheckLogServiceApi;

    @Autowired
    MemberUserRoleServiceApi memberUserRoleServiceApi;

//    /**
//     * 获取汽摩卡券类型列表
//     */
//    @RequestMapping(value="",method = RequestMethod.GET)
//    public String list(Model model){
//        DataSourceHolder.setDataSource(DataSource.DATASOURCE_COMMON);
//        //获取汽摩卡券项目列表
//        List<MotorcycleDto> motorcycleDtoList = motorcycleServiceApi.queryList();
//        if(motorcycleDtoList != null){
//            model.addAttribute("motorcycleList",motorcycleDtoList);
//        }
//        //获取核销人列表
//        MemberUserRoleDto memberUserRoleDto = new MemberUserRoleDto();
//        memberUserRoleDto.setRoleId(BusinessType.MemberRoleType.SELLERS.getCode());
//        List<MemberUserRoleDto> userRoleDtoList = memberUserRoleServiceApi.selectMemberRoleList(memberUserRoleDto);
//        model.addAttribute("userRoleDtoList",userRoleDtoList);
//        return "product/auditManage/auditManage_list";
//    }

    /**
     * 核销记录列表
     */
    @RequestMapping(value = "/json", method = RequestMethod.GET)
    @ResponseBody
    public PageBean selectCheckLogList(MemberCheckLogRequest request) {
        Ensure.that(request).isNotNull("04000001");
        Pager pager = new Pager();
        pager.setPageSize(request.getPageSize());
        pager.setPageNum(request.getPageNum());
        DataSourceHolder.setDataSource(DataSource.DATASOURCE_COMMON);
//        PageInfo<MemberCheckLogDto> pageInfo = memberCheckLogServiceApi.selectCheckLogList(pager, DozerUtils.map(request, MemberCheckLogDto.class));
//        if(null!=pageInfo){
//            List<MemberCheckLogDto> list = pageInfo.getList();
//            return new PageBean<MemberCheckLogResponse>(pageInfo.getTotal(), DozerUtils.maps(list, MemberCheckLogResponse.class));
//        }
        return null;
    }
}
